/** CS2340 Spring 2011 Project
 *  Team: 40 Jiggawatt Hard Driver
 *  Suk Hwan Hong
 *  Rhys Saraceni
 *  Travis Cooper
 *  Luke Stubb
 *
 * @author 40 Jiggawatt Hard Driver
 * @version 1.0 
 */

// $codepro.audit.disable com.instantiations.assist.eclipse.analysis.audit.rule.effectivejava.alwaysOverridetoString.alwaysOverrideToString, numericLiterals
package edu.gatech.jiggawatt.office.model;

import java.io.Serializable;

/**
 * Represents a general User
 * @author 40 Jiggawatt Hard Driver
 * @version 1.0 
 */
public class User implements Serializable { // $codepro.audit.disable declareDefaultConstructors
	
	/**
	 * Field id.
	 */
	private String id;
	
	/**
	 * Field password.
	 */
	private String password;
	
	/**
	 * Field userType.
	 */
	private int userType; // Admin = 0, Patient = 1, Nurse = 2, Doctor = 3
	
	/**
	 * Field firstName.
	 */
	private String firstName;
	
	/**
	 * Field lastName.
	 */
	private String lastName;
	
	/**
	 * Field age.
	 */
	private int age;
	
	/**
	 * Field gender.
	 */
	private int gender;
	
	/**
	 * Field address.
	 */
	private String address;
	
	/**
	 * Field phone.
	 */
	private String phone;
	
	/**
	 * Field email.
	 */
	private String email;
	
	/**
	 * Field failedLogin.
	 */
	private int failedLogin = 0;
	
	/**
	 * Field suspended.
	 */
	private boolean suspended = false;
	

	/**
	 * Constructor for User.
	 * @param id String
	 * @param pw String
	 * @param firstName String
	 * @param lastName String
	 * @param userType int
	 */
	public User(String id, String pw, String firstName, String lastName, int userType) {
		this.id = id;
		password = pw;
		this.firstName = firstName;
		this.lastName = lastName;
		this.userType = userType;
	}
	
	/**
	 * Constructor for user
	 * @param id
	 * @param pw
	 * @param firstName
	 * @param lastName
	 * @param age
	 * @param gender
	 * @param address
	 * @param phone
	 * @param email
	 * @param userType
	 */
	public User(String id, String pw, String firstName, String lastName, int age, int gender, String address, String phone, String email, int userType) {
		this.id = id;
		password = pw;
		this.firstName = firstName;
		this.lastName = lastName;
		this.userType = userType;
		this.age = age;
		this.gender = gender;
		this.address = address;
		this.phone = phone;
		this.email = email;
		this.userType = userType;
	}
	
	/**
	 * sets id
	 * @param id
	 */
	public void setId(String id) {
		this.id = id;
	}

	/**
	 * gets id
	 * @return id
	 */
	public String getId() {
		return id;
	}
	
	/**
	 * sets user type
	 * @param userType
	 */
	public void setUserType(int userType) {
		this.userType = userType;
	}

	/**
	 * gets user type.
	 * @return user type
	 */
	public int getUserType() {
		return userType;
	}

	/**
	 * sets first name
	 * @param firstName
	 */
	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}
	
	/**
	 * sets last name
	 * @param lastName
	 */
	public void setLastName(String lastName) {
		this.lastName = lastName;
	}
	
	/**
	 * gets first name
	 * @return first name
	 */
	public String getFirstName() {
		return firstName;
	}
	
	/**
	 * gets last name
	 * @return last name
	 */
	public String getLastName() {
		return lastName;
	}

	/**
	 * gets full name
	 * @return full name
	 */
	public String getFullName() {
		return firstName + " " + lastName;
	}
	
	/**
	 * sets age
	 * @param age
	 */
	public void setAge(int age) {
		this.age = age;
	}

	/**
	 * gets age
	 * @return age
	 */
	public int getAge() {
		return age;
	}

	/**
	 * sets gender
	 * @param gender
	 */
	public void setGender(int gender) {
		this.gender = gender;
	}

	/**
	 * gets gender
	 * @return gender
	 */
	public int getGender() {
		return gender;
	}

	/**
	 * sets address
	 * @param address
	 */
	public void setAddress(String address) {
		this.address = address;
	}

	/**
	 * gets address
	 * @return address
	 */
	public String getAddress() {
		return address;
	}

	/**
	 * sets phone
	 * @param phone
	 */
	public void setPhone(String phone) {
		this.phone = phone;
	}

	/**
	 * gets phone
	 * @return phone
	 */
	public String getPhone() {
		return phone;
	}

	/**
	 * sets email
	 * @param email
	 */
	public void setEmail(String email) {
		this.email = email;
	}

	/**
	 * gets email
	 * @return email
	 */
	public String getEmail() {
		return email;
	}

	/**
	 * reset login attempt counter to 0
	 */
	public void clearFailedLogin(){
		failedLogin = 0;
	}
	
	/**
	 * increment the login attempt counter
	 * the user is suspended once the failedLogin == 3
	 */
	public void incFailedLogin() {
		failedLogin++;
		if (3 == failedLogin) {
			suspended = true;
		}
	}

	/**
	 * gets failed login
	 * @return int
	 */
	public int getFailedLogin() {
		return failedLogin;
	}

	/**
	 * suspends user
	 */
	public void suspend() {
		suspended = true;
	}
		
	/**
	 * sets suspended
	 * @param suspended
	 */
	public void setSuspended(int suspended)
	{
		if (0 == suspended)
		{
			this.suspended = false;
		}
		else
		{
			this.suspended = true;
		}			
	}
	
	/**
	 * gets suspended
	 * @return suspended
	 */
	public int getSuspended()
	{
		if (suspended)
		{
			return 1;
		}
		else
		{
			return 0;
		}
	}
	
	/**
	 * unsuspend user
	 */
	public void unSuspend() {
		suspended = false;
	}

	/**
	 * checks if user is suspended
	 * @return true if suspended, false otherwise
	 */
	public boolean isSuspended() {
		return suspended;
	}
		
	/**
	 * sets password of user
	 * @param password
	 */
	public void setPassword(String password){
		this.password = password;
	}
	
	/**
	 * checks if password matches
	 * @param password
	 * @return true if password matches, false otherwise
	 */
	public boolean checkPassword(String password){ // $codepro.audit.disable booleanMethodNamingConvention
		return (this.password).equals(password);
	}
	
	/**
	 * returns string format of user
	 * @return string format of user
	 */
	public String toString()
	{
		return firstName + " " + lastName;
	}
}